//---------------------------------------------------------------------------

#ifndef D_kls_stH
#define D_kls_stH

//#define __WKL_STATIC_USER
#include "Wkls.h"
#if !defined( Ex_BaseH )
  #include "Ex_Base.h"
#endif



class TDKLS                 //type to be submited by user
{                        //will be in user`s .h file
 public:
 TKLS * DKLS ;         //holder for TKLS that will be opened later (later will change to *void in user's file)
 char * PathNameFound;      // = NULL if no file found = DKLS=NULL, delete object.
 int count;
 TDKLS ()   // default constructor
 {
  DKLS = NULL;
  count=0;
 }
 ~TDKLS ()
 {
  if (DKLS != NULL)
  {
   TKLS * KLSFun = DKLS;
   if ( 0 ==  --(count) )
    delete KLSFun;            //this will free the mem at adress KLSFun
   DKLS = NULL;
  }
 }
};

 //
// #define BASEEXTERNFUNC extern "C" __declspec(dllexport)
//#define BASEEXPORTFUNC __stdcall


extern "C" __declspec(dllexport) int __stdcall Dopen(TKLS **KLSTmp, char * Dpath,
                         char *reg="R", char *parol="ABD",bool individual = false);
extern "C" __declspec(dllexport) int  __stdcall  Dclose(TKLS **KLSTmp);
extern "C" __declspec(dllexport) bool  __stdcall DIsExistCodKls(TKLS **KLSTmp, const TCod &c, TTypeIE t);
extern "C" __declspec(dllexport) int  __stdcall  DGetPon (TKLS **KLSTmp,const TCod &c, TTypeIE t, char *Pon,int *err);
extern "C" __declspec(dllexport) int  __stdcall  DCodFromPon (TKLS **KLSTmp, const TCod &FirstCod, TTypeIE Type,  AnsiString &Pon,
                             TCodPonKls *Array,  int &SizeCodPonArray, bool CaseSensitive = true);
extern "C" __declspec(dllexport) int  __stdcall  DListSubIE (TKLS **KLSTmp, const TCod &CodIE, TTypeIE TypeIE, TCodPonKls *Array, int &SizeCodPonArray);
extern "C" __declspec(dllexport) int  __stdcall  DIsEndLevel (TKLS **KLSTmp, const TCod &c, TTypeIE t, bool &EndLevel);
extern "C" __declspec(dllexport) int  __stdcall  DFindIE_Spr (TKLS **KLSTmp, const TCod &FirstCod,
            TTypeIE t, BASE_INT Position, BASE_INT FindValue, TCodPonKls *Array, int &SizeFoundArray);
extern "C" __declspec(dllexport) int  __stdcall  DFindIE_SprName (TKLS **KLSTmp,const TCod &FirstCod, TTypeIE t, char *NamePos,
                         BASE_INT FindValue,TCodPonKls *Array, int &SizeValueArray);

extern "C" __declspec(dllexport) int  __stdcall  DGetSpravka (TKLS **KLSTmp, const TCod &c, TTypeIE t, BASE_INT *spr, int sizeSpr, int *info);
extern "C" __declspec(dllexport) int  __stdcall  DSpravkaPosition(TKLS **KLSTmp, const TCod &c, TTypeIE t, BASE_INT Position, BASE_INT &Value, int *info=0);
extern "C" __declspec(dllexport) BASE_INT __stdcall DFindPosSpr (TKLS **,TTypeIE t, char *NamePos);
extern "C" __declspec(dllexport) int  __stdcall  DSpravkaPositionName(TKLS **KLSTmp, const TCod &c, TTypeIE t, char *NamePos, BASE_INT &Value, int *info=0 )  ;
extern "C" __declspec(dllexport) int  __stdcall  DSpravkaDop (TKLS **KLSTmp, const TCod &c, TTypeIE t, BASE_INT Position, TValuePosition *Array, int &SizeValueArray,int *info=0);
extern "C" __declspec(dllexport) int  __stdcall  DSpravkaDopName  (TKLS **KLSTmp, const TCod &c, TTypeIE t, char *NamePos, TValuePosition *Array, int &SizeValueArray, int *info=0);
extern "C" __declspec(dllexport) int  __stdcall  DDictionarySpr  (TKLS **KLSTmp,TTypeIE t, BASE_INT Position, TValuePosition *Array, int SizeValueArray);
extern "C" __declspec(dllexport) int  __stdcall  DDictionarySprName  (TKLS **KLSTmp,TTypeIE t,
                                                char *NamePos, TValuePosition *Array, int SizeValueArray);
extern "C" __declspec(dllexport) int  __stdcall  DGetTypeValue (TKLS **KLSTmp,const TCod &c, TValuePosition *Array, int &SizeValueArray, int *info=0);
extern "C" __declspec(dllexport) int  __stdcall  DAllTypeValue (TKLS **KLSTmp,TValuePosition *Array, int SizeValueArray);
extern "C" __declspec(dllexport) int  __stdcall  DLgsKlsObj (TKLS **KLSTmp,const TCod &c,BASE_INT64 &lgs,BASE_INT64 &lgs_s);
extern "C" __declspec(dllexport) int  __stdcall  DLgsKlsPr  (TKLS** , const TCod &c,TTypeIE typ, BASE_INT64 &lgs,BASE_INT64 &lgs_s);
extern "C" __declspec(dllexport) int  __stdcall  DSelectRelns (TKLS **KLSTmp,const TCod &c, TTypeIE t, TSelRelnQuery &q, TRelation *Array, int &SizeRelnsArray);
extern "C" __declspec(dllexport) int  __stdcall  DGetContTypesReln (TKLS **KLSTmp,int NumSp, TTypeRelation *Array, int SizeTypeRelnsArray);
extern "C" __declspec(dllexport) int  __stdcall  DUseInScale(TKLS **KLSTmp,const TCod &c, TTypeIE t, float mapScale=0);
extern "C" __declspec(dllexport) bool __stdcall
           DIsInsideNumScale (TKLS **KLSTmp, TTypeIE t, BASE_INT numScale, float mapScale,
                              unsigned long *Interval=0);
extern "C" __declspec(dllexport) int  __stdcall  DBestNumScale(TKLS **KLSTmp, TTypeIE t, float mapScale);
extern "C" __declspec(dllexport) void __stdcall
           Get_Official_Cod  (TKLS **KLSTmp,char *Name,TTypeIE type,TCod *Exit_Cod,int *Err);
extern "C" __declspec(dllexport) int  __stdcall  DSelectCodKLS(TKLS **KLSTmp, TCod &Cod, TTypeIE t, TCod *TopCod=NULL);

extern "C" __declspec(dllexport) int  __stdcall  DSelAddSvPrInObj(TKLS **KLSTmp, const TCod &cObj, int InList, TCod &cSvPr, TTypeIE &t);
extern "C" __declspec(dllexport) int  __stdcall  DSelAddXarInCXar(TKLS **KLSTmp, const TCod &cCXar, TCod &cXar);
extern "C" __declspec(dllexport) int  __stdcall  DSelAddXarInObj(TKLS **KLSTmp, const TCod &cObj, TCod &cXar);
extern "C" __declspec(dllexport) int  __stdcall  DSelAddXarInPr (TKLS **KLSTmp, const TCod &cPr, TCod &cXar);



//---------------------------------------------------------------------------
#endif





